apiVersion: logging.kubesphere.io/v1alpha2
kind: Output
metadata:
  name: es
  namespace: kubesphere-logging-system
  labels:
    logging.kubesphere.io/enabled: "true"
    logging.kubesphere.io/component: "logging"
spec:
  matchRegex: (?:kube|service)\.(.*)
  es:
    host: "{% if common.es.externalElasticsearchHost is defined and common.es.externalElasticsearchHost != "" %}{{ common.es.externalElasticsearchHost }}{% else %}elasticsearch-logging-data.kubesphere-logging-system.svc{% endif %}"
    port: {% if common.es.externalElasticsearchPort is defined and common.es.externalElasticsearchPort != "" %}{{ common.es.externalElasticsearchPort }}{% else %}9200{% endif %}

{% if common.es.basicAuth is defined and common.es.basicAuth.enabled is defined and common.es.basicAuth.enabled %}
{% if common.es.basicAuth.username is defined and common.es.basicAuth.username != "" %}
    httpUser:
      valueFrom:
        secretKeyRef:
          key: "username"
          name: "elasticsearch-credentials"
{% endif %}
{% if common.es.basicAuth.password is defined and common.es.basicAuth.password != "" %}
    httpPassword:
      valueFrom:
        secretKeyRef:
          key: "password"
          name: "elasticsearch-credentials"
{% endif %}
{% endif %}
    bufferSize: 20MB
    traceError: true
    generateID: true
    logstashPrefix: "ks-{{ common.es.elkPrefix }}-log"
    logstashFormat: true
    timeKey: "@timestamp"
{% if common.es.externalElasticsearchProtocol is defined and common.es.externalElasticsearchProtocol == "https" %}
    tls:
      verify: false
{% endif %}
